﻿@namespace AntDesign
@inherits AntDomComponentBase

<div class="@ClassMapper.Class" style="@Style">

    @if (Avatar.IsT0 && Avatar.AsT0 != "")
    {
        <div class="ant-list-item-meta-avatar">
            <Avatar Src="@Avatar.AsT0"></Avatar>
        </div>
    }

    @if (Avatar.IsT1 && Avatar.AsT1 != null)
    {
        <div class="ant-list-item-meta-avatar">
            @Avatar.AsT1
        </div>
    }

    <div class="ant-list-item-meta-content">
        <div>
            <h4 class="ant-list-item-meta-title">
                @Title
            </h4>
        </div>
        <div class="ant-list-item-meta-description">
            @Description
        </div>
    </div>
</div>

@code{
    public string PrefixName { get; set; } = "ant-list-item-meta";

    [Parameter] public RenderFragment Title { get; set; }

    [Parameter] public OneOf.OneOf<string, RenderFragment> Avatar { get; set; }

    [Parameter] public string Description { get; set; }

    protected override void OnInitialized()
    {
        base.OnInitialized();
        SetClassMap();
    }

    protected override void OnParametersSet()
    {
        base.OnParametersSet();
        SetClassMap();
    }

    protected void SetClassMap()
    {
        ClassMapper.Clear()
            .Add(PrefixName);
    }
}